<template>
  <div></div>
  <!-- <div class="h_page" v-if="isLoading">
    <div class="loading_wrap">
      <van-loading class="global_loading" color="#1989fa" type="spinner" size="50px" vertical>加载中...</van-loading>
    </div>
  </div> -->
</template>

<script setup>
import { getOneKeySignFrontNotify, GetParamTmp } from '@/api/api.js'
import { useRouter, useRoute } from 'vue-router'
import { reactive, ref, onMounted, getCurrentInstance } from 'vue'
// import { useCounterStore } from '../../store/counter';

const router = useRouter()
const { proxy } = getCurrentInstance()
const frontUrl = ref('');
const paramsUrl = ref('');
// const isLoading = ref(false)

onMounted(() => {
  getAipList()
})
const getAipList = async () => {
  // http://10.98.143.86:3002/#/
  // window.location.href = 'http://10.10.55.59:8888/cashierFrontH5/index.html#/home?oriAmount=1&amount=1&retUrl=https%3A%2F%2Fwww.xxx.com%2F&tradeNo=3404171912303983&orderId=a47733&goodsInf=%E6%B5%8B%E8%AF%95&merPlain=amount%3D1%26amt_type%3DRMB%26charset%3DUTF-8%26expire_time%3D1440%26gate_id%3DPSBC%26goods_inf%3D%E6%B5%8B%E8%AF%95%26mer_date%3D20240417%26mer_id%3D9996%26notify_url%3Dhttps%3A%2F%2Fwww.xxx.com%2F%26order_id%3Da47733%26pay_type%3DDEBITCARD%26quick_sign_type%3Dquick-web%26res_format%3DHTML%26ret_url%3Dhttps%3A%2F%2Fwww.xxx.com%2F%26service%3Dreq_front_cashier_pay_h5%26version%3D4.0&merName=%E8%81%94%E5%8A%A8%E6%B5%8B%E8%AF%95&rpid=WSP1912519d2e9e1&isShowFrame=Y&instId=20000001&trace=3404171912680003&payType=7&expireTime=2024-04-18+19%3A12%3A51.763&service=req_front_cashier_pay_h5&merSign=eKYEcGPP%2BYmc1oNs2HlvzgfhKdbGw7VDV6fx3JVw%2BFB%2BvSYv1B7gnrKgfF0%2B0964nfOHw1%2Banyq13%2FPNuAEZhuj2a%2BzDyK2EqihM4SO2OpPvkGK2eoZ2vKAYgd92EDI01%2BBGgLz9l%2Fxgiuo4o4Gzmoy%2BGIVQvuXAD08CFcuNFws%3D&notifyUrl=http%3A%2F%2F10.10.55.55%3A9090%2Fspay%2Fpay%2FwebPluginNotify.do&merId=9996&binBankId=B006&busiPayUrl=http%3A%2F%2F10.10.55.55%3A8187%2Fpaybusi%2FA01002&orderDate=20240417&payDate=20240417&sign=0cf3988f3eae419adfe42fcefe7636bcc8bf3002'
  // return
  var params = proxy.$globalFn.getUrlParameters(window.location.hash)
  if (params) {
    window.console.log(params)
    if (params.paySeq) {
      proxy.$globalFn.setStorage('paySeq', params.paySeq || '')
      let res = await getOneKeySignFrontNotify(JSON.stringify(params))
      let res2 = await GetParamTmp({
        merId: res.data.merId,
        orderId: res.data.orderId,
        merDate: res.data.merDate,
      })
      try {
        if (res.retCode == '0000') {
          frontUrl.value = res.data.frontUrl;
          // proxy.$globalFn.setStorage('phone', res.data.mobileId || '')
        }
      } catch (err) {
        proxy.$showToast(res.retMsg)
      }

      if (res2.retCode == '0000') {
        paramsUrl.value = res2.data || ''
        if (paramsUrl.value.includes('strPhone')) {
          let str = paramsUrl.value.split("strPhone")
          paramsUrl.value = str[0]
          proxy.$globalFn.setStorage('phone', str[1] || '')
        }
      }
      if (frontUrl.value && paramsUrl.value) {
        window.console.log(paramsUrl.value)
        if (paramsUrl.value.includes('quick_sign_type')) {
          window.location.href = frontUrl.value + '?' + paramsUrl.value
        } else {
          window.location.href = frontUrl.value + '?' + paramsUrl.value + '&quick_sign_type=quick-web'
        }
      }

    } else {
      proxy.$showToast("paySeq字段数据为空！")
    }
  } else {
    proxy.$showToast("缺少paySeq字段！")
  }
}

</script>

<style lang="sass" scoped>
.page
  width: 100%
  background: #F8F8F8
.h_page
  position: fixed
  top: 50%
  left: 50%
  transform: translate(-50%,-50%)
  width: 100%
  height: 100vh
  background-color: rgba(0, 0, 0, 0)
  display: flex
  justify-content: center
  align-items: center
  z-index: 99999
.loading_wrap
  padding: 30px 40px
  border-radius: 10px
  // position: fixed
  // left: 50%
  // top: 50%
  // transform: translate(-50%,-50%)
  background-color:rgba(0, 0, 0, 0.5)
  z-index: 999999

::v-deep .global_loading
  color:#fff !important
  pointer-events: none
</style>
